// pages/my/my.js
const app = getApp();
const {
  noticelist
} = require('../../config.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    noticelist:[],
    nolistTip:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    app.appRequest({
      url: noticelist,
      success: (res) => {
        let noticelist = res.data.pageBean.result;
        if (noticelist.length > 0){
          console.log(111)
          noticelist.map((item) => {
            item.title = item.title;
            item.dateAdd = item.dateAdd.slice(5, 10)
          })
          this.setData({
            nolistTip: 0,
            noticelist: noticelist
          })
        }else{
          this.setData({
            nolistTip: -1
          })
        }
      }
    })
  },


  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.showNavigationBarLoading()
    app.appRequest({
      url: noticelist,
      success: (res) => {
        wx.hideNavigationBarLoading();
        wx.stopPullDownRefresh();
        let noticelist = res.data.pageBean.result;
        this.setData({
          noticelist: noticelist
        })
      }
    })
  },
  navigatorToNotice_info: function(e) {
    let {
      id
    } = e.currentTarget.dataset;
    wx.navigateTo({
      url: `/pages/notice_info/notice_info?id=${id}`,
    })
  }

  // navigatorToFeedback: function () {
  //   wx.navigateTo({
  //     url: '/pages/feedback/feedback',
  //   })
  // }
})